import 'package:appflutterhomeschool/api/api_service.dart';
import 'package:appflutterhomeschool/api/dio_utils.dart';
import 'package:appflutterhomeschool/model/templates_model.dart';
import 'package:flutter/material.dart';

class NewNotificationViewModel extends ChangeNotifier {
  BuildContext me;
  int type;
  List<TemplatesModel> templatesList = [];

  NewNotificationViewModel(this.me, type);

  initView() {
    if (type == null) {
      type = 0;
    }
    templatesList.clear();
    Dio2Utils.getInstance().post(ApiService.templates, {"type:": type},
        (successCallBack) {
      Map<String, dynamic> mapData = successCallBack["data"];
      if (mapData == null) {
        return;
      }
      templatesList.add(TemplatesModel());
      List templates = mapData["templates"];
      templates.forEach((element) {
        templatesList.add(TemplatesModel.fromJson(element));
      });
      notifyListeners();
    }, (errorCallBack) {});
  }
}
